import com.jiangnan.components.CustomSwitchButton;

import javax.swing.*;
import java.awt.*;

public class SettingsPageExample {
    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> {
            JFrame frame = new JFrame("设置页面");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(400, 300);

            // 创建三个选项卡面板
            JTabbedPane tabbedPane = new JTabbedPane();

            // 创建通用设置面板
            JPanel generalSettingsPanel = createGeneralSettingsPanel();
            tabbedPane.addTab("通用设置", generalSettingsPanel);

            // 创建外观设置面板
            JPanel appearanceSettingsPanel = createAppearanceSettingsPanel();
            tabbedPane.addTab("外观设置", appearanceSettingsPanel);

            // 创建系统设置面板
            JPanel systemSettingsPanel = createSystemSettingsPanel();
            tabbedPane.addTab("系统设置", systemSettingsPanel);

            frame.add(tabbedPane);
            frame.setVisible(true);
        });
    }

    // 创建通用设置面板
    private static JPanel createGeneralSettingsPanel() {
        JPanel panel = new JPanel(new GridLayout(3, 2));
        panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

        // 添加开关选项
        panel.add(new JLabel("选项1"));
        panel.add(new CustomSwitchButton());
        panel.add(new JLabel("选项2"));
        panel.add(new JCheckBox());

        // 添加文本输入框
        panel.add(new JLabel("文本1"));
        panel.add(new JTextField());
        panel.add(new JLabel("文本2"));
        panel.add(new JTextField());

        // 添加选择框
        panel.add(new JLabel("选择框1"));
        panel.add(new JComboBox<>(new String[]{"选项A", "选项B", "选项C"}));

        return panel;
    }

    // 创建外观设置面板
    private static JPanel createAppearanceSettingsPanel() {
        JPanel panel = new JPanel(new GridLayout(3, 2));
        panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

        // 添加开关选项
        panel.add(new JLabel("外观选项1"));
        panel.add(new JCheckBox());
        panel.add(new JLabel("外观选项2"));
        panel.add(new JCheckBox());

        // 添加文本输入框
        panel.add(new JLabel("外观文本1"));
        panel.add(new JTextField());
        panel.add(new JLabel("外观文本2"));
        panel.add(new JTextField());

        // 添加选择框
        panel.add(new JLabel("外观选择框1"));
        panel.add(new JComboBox<>(new String[]{"选项X", "选项Y", "选项Z"}));

        return panel;
    }

    // 创建系统设置面板
    private static JPanel createSystemSettingsPanel() {
        JPanel panel = new JPanel(new GridLayout(3, 2));
        panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

        // 添加开关选项
        panel.add(new JLabel("系统设置1"));
        panel.add(new JCheckBox());
        panel.add(new JLabel("系统设置2"));
        panel.add(new JCheckBox());

        // 添加文本输入框
        panel.add(new JLabel("系统文本1"));
        panel.add(new JTextField());
        panel.add(new JLabel("系统文本2"));
        panel.add(new JTextField());

        // 添加选择框
        panel.add(new JLabel("系统选择框1"));
        panel.add(new JComboBox<>(new String[]{"选项M", "选项N", "选项O"}));

        return panel;
    }
}
